package cn.source.config;

import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.RSAPublicKeyConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author coderwaves
 * @date 2023/2/15 16:41
 */
@Configuration
public class WxRSAAutoCertificateConfig {
    @Resource
    private WxPayV3Config wxPayV3Config;
    @Bean
    public RSAPublicKeyConfig wxAutoCertificateConfig() {
        return new RSAPublicKeyConfig.Builder()
                .merchantId(wxPayV3Config.getMchId())
                .privateKeyFromPath(wxPayV3Config.getPrivateKeyPath())
                .publicKeyFromPath(wxPayV3Config.getPublicKeyPath())
                .publicKeyId(wxPayV3Config.getSzypublicId())
                .merchantSerialNumber(wxPayV3Config.getMchSerialNo())
                .apiV3Key(wxPayV3Config.getApiV3Key())
                .build();
    }
}
